//
//  BseViewController.m
//  RPay
//
//  Created by hzy on 2017/10/30.
//  Copyright © 2017年 Charlie. All rights reserved.
//

#import "BseViewController.h"
#import "HexColors.h"

@interface BseViewController ()
{
    UIButton *leftBarButton;
    UIButton *rightBarButton;
}
@end

@implementation BseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void)alertWithTitle:(NSString *)title message:(NSString *)message handler:(void (^ __nullable)(UIAlertAction *action))handler
{
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
        UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:handler];
        [alertController addAction:alertAction];
    
        [self presentViewController:alertController animated:YES completion:nil];

    
    
    
}

-(void)addNavigationBarLeftButtonItem
{
    leftBarButton = [UIButton buttonWithType:UIButtonTypeSystem];
    leftBarButton.frame = CGRectMake(0, 0, 30, 40);
    [leftBarButton addTarget:self.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
    [leftBarButton setImage:[[UIImage imageNamed:@"icon_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:leftBarButton];
    self.navigationItem.leftBarButtonItem = item;
}
-(void)addNavigationBarRightButtonItemWithInfo:(NSString *)title target:(id)target action:(SEL)action
{
    rightBarButton = [UIButton buttonWithType:UIButtonTypeSystem];
    rightBarButton.frame = CGRectMake(0, 0, 30, 40);
    [rightBarButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [rightBarButton setTitle:title forState:0];
    rightBarButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [rightBarButton setTitleColor:[UIColor hx_colorWithHexRGBAString:@"#333333"] forState:0];
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:rightBarButton];
    self.navigationItem.rightBarButtonItem = item;
}
-(BOOL)checkNetworkData:(id)data{

    if ((data[@"statue"]&&[data[@"statue"] isEqualToString:@"SUCCESS"])||([data[@"code"] integerValue] == 200)) {
        return YES ;
        
    }else{
    
        if (data[@"erroMsg"]) {
             [self alertWithTitle:@"提示" message:data[@"erroMsg"] handler:NULL];
        }else{
         [self alertWithTitle:@"提示" message:data[@"msg"] handler:NULL];
        }
        
        
        
    }

    return NO;
}
-(void)alertNetworkError{

    [self alertWithTitle:@"提示" message:@"网络连接失败，请重试！" handler:NULL];
}

@end
